/*
 * Copyright(c) 2018 优居科技 All rights reserved.
 * distributed with this file and available online at
 * http://www.yjyz.com/
 */
package com.zb.api.business.controller;


import com.zb.api.business.dto.PosPlanCommentDto;
import com.zb.api.business.service.IPosPlanCommentService;
import com.zb.api.common.models.Page;
import com.zb.api.common.models.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


/**
* 方案评论表
 *
 * @author cwp
 * @version v1.0
 * @CreationTime: - 2022-02-08 14:19:31
 * @Description:
 */
@Api("方案评论表")
@RestController
@Slf4j
@RequestMapping("/posPlanComment")
public class PosPlanCommentController {

    @Resource
    private IPosPlanCommentService posPlanCommentService;

    @GetMapping("/lists")
    @ApiOperation(value="获取分页方案评论表数据", nickname = "posPlanCommentList")
    public Result<Page<PosPlanCommentDto>> posPlanCommentList(@RequestParam(defaultValue = "1") @ApiParam(name = "pageNo", value = "当前页") int pageNo,
                                                              @RequestParam(defaultValue = "10") @ApiParam(name = "pageSize", value = "每页记录数") int pageSize,
                                                              PosPlanCommentDto posPlanCommentDto){
        return new Result("查询成功", posPlanCommentService.getPosPlanCommentList(pageNo, pageSize, posPlanCommentDto));
    }

    @GetMapping("/{id}")
    @ApiOperation(value="获取方案评论表", nickname = "getPosPlanComment")
    public Result<PosPlanCommentDto> getPosPlanComment(@PathVariable("id") String id) {
        return new Result("查询成功", posPlanCommentService.get(id));
    }

    @PutMapping
    @ApiOperation(value="更新方案评论表", nickname = "updatePosPlanComment")
    public Result<Integer> updatePosPlanComment(@RequestBody PosPlanCommentDto posPlanCommentDto) {
        return new Result("修改成功", posPlanCommentService.update(posPlanCommentDto));
    }

    @PostMapping
    @ApiOperation(value="插入方案评论表", nickname = "insertPosPlanComment")
    public Result<Integer> insertPosPlanComment(@RequestBody PosPlanCommentDto posPlanCommentDto) {
        return new Result("录入成功", posPlanCommentService.insert(posPlanCommentDto));
    }


    @PostMapping("/add")
    @ApiOperation(value="添加方案评论", nickname = "insertPlanComment")
    public Result<Integer> insertPlanComment(@RequestBody PosPlanCommentDto posPlanCommentDto) throws IllegalAccessException {
        return new Result("录入成功", posPlanCommentService.insertPlanComment(posPlanCommentDto));
    }

    @PostMapping("/del")
    @ApiOperation(value="删除方案评论", nickname = "delPlanComment")
    public Result<Integer> delPlanComment(@RequestBody PosPlanCommentDto posPlanCommentDto) throws IllegalAccessException {
        return new Result("操作成功", posPlanCommentService.delPlanComment(posPlanCommentDto.getId()));
    }

    @PostMapping("/getList")
    @ApiOperation(value="评论列表", nickname = "getList")
    public Result<Page<PosPlanCommentDto>> getList(@RequestBody PosPlanCommentDto posPlanCommentDto) throws IllegalAccessException {
        return new Result("查询成功", posPlanCommentService.getList(posPlanCommentDto));
    }

}
